<template>
	<view class="mainpadding2">
		<view class="mainpadding_top ffffff flexbetween radius" v-for="item in list.data" :key="item.id">
			<view class="flexleft">
				<image :src="item.teacher.avatar" class="headimg" mode=""></image>
				<view class="flexcolumnbet margin_left" style="height: 100rpx;">
					<view class="titletext bold hei_text">{{item.teacher.username}}</view>
					<view class="xiaohui">{{item.teacher.description}}</view>
				</view>
			</view>
			<view class="bghui xiaohei" style="padding: 10rpx 20rpx;" @click="jiechu(item.teacher_id)">解除拉黑</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/teacher/teacherblacklist', 'GET', {
					page: page || 1
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jiechu(id){
				httpRequest.request('/api/teacher/cancel_blacklist', 'POST', {
					teacher_id:id
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.init()
					}
				})
			}
		}
	}
</script>

<style>

</style>
